<?php
 class manageController extends AdminController
 {
     public function init()
     {
         $this->tableName='page';
         parent::init();
     }
     public function indexAction()
     {
         $this->list=$this->model->order('ordernum asc,id desc')->getlist();
         $this->display();
     }
     public function addAction()
     {
         if (IS_POST) {
             $zym_7['name']=I('name', 'str', '');
             $zym_7['key']=I('key', 'en', '');
             $zym_7['litpic']=I('litpic', 'str', '');
             $zym_7['ordernum']=I('ordernum', 'int', '');
             $zym_7['type']=I('type', 'int', 1);
             $zym_7['status']=I('status', 'int', 1);
             $zym_7['content']=($zym_7['type']==1)?text::simditor(I('content', 'str', '')):I('htmlcontent', 'str', '');
             if ($this->model->add($zym_7)) {
                 $this->success('添加成功', U('index'));
             } else {
                 $this->error('添加失败');
             }
         }
         $this->display();
     }
     public function editAction()
     {
         $zym_6=I('request.id', 'int', 0);
         $zym_5=$this->model->where(array('id'=>$zym_6))->find();
         if (IS_POST) {
             $zym_7['name']=I('name', 'str', '');
             $zym_7['key']=I('key', 'en', '');
             $zym_7['litpic']=I('litpic', 'str', '');
             $zym_7['ordernum']=I('ordernum', 'int', '');
             $zym_7['type']=I('type', 'int', 1);
             $zym_7['status']=I('status', 'int', 1);
             $zym_7['content']=($zym_7['type']==1)?text::simditor(I('content', 'str', '')):I('htmlcontent', 'str', '');
             $zym_7['id']=$zym_6;
             if ($this->model->edit($zym_7)) {
                 $this->success('修改成功', U('index'));
             } else {
                 $this->error('修改失败');
             }
         }
         $this->info=$zym_5;
         $this->display();
     }
 }
